import java.util.Scanner;

import org.junit.Test;

public class HomeWork3 {

	@Test
	public void test1() {
		for (int i = 1; i <= 9; i++) {
			for (int j = 1; j <= i; j++) {
				// 3*9=27
				System.out.print(j + "*" + i + "=" + (j * i) + "\t");
			}
			System.out.println();
		}
	}
		
//	  *
//   * *
//  * * *
// * * * *
//* * * * *
	
	@Test
	public void test2() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入月份：");
		int month = scanner.nextInt();
		
		switch(month) {
		case 1:
			System.out.println("31");
			break;
		case 2:
			//System.out.println("31");
			System.out.println("请输入年份：");
			int year = scanner.nextInt();
			
			break;
		case 3:
			System.out.println("31");
			break;
		case 4:
			System.out.println("30");
			break;
		case 5:
			System.out.println("31");
			break;
		case 6:
			System.out.println("30");
			break;
		case 7:
			System.out.println("31");
			break;
		case 8:
			System.out.println("31");
			break;
		default:
			System.out.println("输入月份错误：" + month);
			break;
		}
	}
	
	@Test
	public void test3() {
		Scanner scanner = new Scanner(System.in);
		System.out.println("请输入月份：");
		int month = scanner.nextInt();
		
		switch(month) {
		case 1:
		case 3:
		case 5:
		case 7:
		case 8:
		case 10:
		case 12:
			System.out.println("31");
			break;
		case 4:
		case 6:
		case 9:
		case 11:
			System.out.println("30");
			break;
		case 2:
			//System.out.println("31");
			System.out.println("请输入年份：");
			int year = scanner.nextInt();
			
			break;
		default:
			System.out.println("输入月份错误：" + month);
			break;
		}
	}
	
	@Test
	public void test4() {
		int scores[] = {0, 0, 1, 2, 3, 5, 4, 5, 2, 8, 7, 6, 9, 5, 4, 
				8, 3, 1, 0, 2, 4, 8, 7, 9, 5, 2, 1, 2, 3, 9};
		int sum0 = 0;
		int sum1 = 0;
		int sum2 = 0;
		int sum3 = 0;
		int sum4 = 0;
		int sum5 = 0;
		int sum6 = 0;
		int sum7 = 0;
		int sum8 = 0;
		int sum9 = 0;
		for (int i = 0; i < scores.length; i++) {
			switch(scores[i]) {
			case 0:
				sum0 += 1;
				break;
			case 1:
				sum1 += 1;
				break;
			case 2:
				sum2 += 1;
				break;
			case 3:
				sum3 += 1;
				break;
			case 4:
				sum4 += 1;
				break;
			case 5:
				sum5 += 1;
				break;
			case 6:
				sum6 += 1;
				break;
			case 7:
				sum7 += 1;
				break;
			case 8:
				sum8 += 1;
				break;
			case 9:
				sum9 += 1;
				break;
			}
		}
		System.out.println("0的个数：" + sum0);
		System.out.println("1的个数：" + sum1);
		System.out.println("2的个数：" + sum2);
		System.out.println("3的个数：" + sum3);
		System.out.println("4的个数：" + sum4);
		System.out.println("5的个数：" + sum5);
		System.out.println("6的个数：" + sum6);
		System.out.println("7的个数：" + sum7);
		System.out.println("8的个数：" + sum8);
		System.out.println("9的个数：" + sum9);
	}
	
	@Test
	public void test14() {
		int scores[] = {0, 0, 1, 2, 3, 5, 4, 5, 2, 8, 7, 6, 9, 5, 4, 
				8, 3, 1, 0, 2, 4, 8, 7, 9, 5, 2, 1, 2, 3, 9};
		int[] array = new int[10];
		for (int i = 0; i < scores.length; i++) {
			switch(scores[i]) {
			case 0:
				// int num = 1;
				// num = num + 1;
				// num++
				// array[0] = array[0] + 1;
				array[0]++;
				break;
			case 1:
				array[1]++;
				break;
			case 2:
				array[2]++;
				break;
			case 3:
				array[3]++;
				break;
			case 4:
				array[4]++;
				break;
			case 5:
				array[5]++;
				break;
			case 6:
				array[6]++;
				break;
			case 7:
				array[7]++;
				break;
			case 8:
				array[8]++;
				break;
			case 9:
				array[9]++;
				break;
			}
		}
		
		for (int i = 0; i < array.length; i++) {
			System.out.println(i + "的个数：" + array[i]);
		}
	}
	
	@Test
	public void work2_1_2() {
		int[] scores={0,0,1,2,3,5,4,5,2,8,7,6,9,5,4,8,3,1,0,2,4,8,7,9,5,2,1,2,3,9};
		for(int i = 0;i <= 9;i++) {
			int sum = 0;
			for(int j = 0;j < scores.length;j++) {
				if(scores[j] == i) {
					sum++;
				}
			}
			System.out.println("数字"+i+"有"+sum+"个");
	   }
	}	
	
	@Test
	public void test44() {
		int[] scores={0,0,1,2,3,5,4,5,2,8,7,6,9,5,4,8,3,1,0,2,4,8,7,9,5,2,1,2,3,9};;
		int oddCount = 0;
		int evenCount = 0;
		for (int i = 0; i < scores.length; i++) {
			if (scores[i] % 2 == 0) {
				evenCount++;
			} else {
				oddCount++;
			}
		}
		
		System.out.println("奇数个数：" + oddCount);
		System.out.println("偶数个数：" + evenCount);
	}
	
	@Test
	public void test6() {
		int array[] = new int[] {1, -1, 56, 8, 99, 2, 12};
		//假设数组中第一个数是最大的
		int max = array[0];
		int min = array[0];
		for (int i = 1; i < array.length; i++) {
			// 后面数组里面的数如果比之前设定max还要大，就把max的值更新一下
			if (array[i] > max) {
				max = array[i];
			} else if (array[i] < min) {
				min = array[i];
			}
		}
		System.out.println("最大值：" + max + "\n" + "最小值：" + min);
	}

}
